from drg_group.yinchuan_2023.Base import message,intersect,SS_VALID
from drg_group.yinchuan_2023.DRG import MDCG_DRG

def group(record):
  adrg_zd=["C15.100x002","C15.100x003","C15.100x004","C15.300","C15.400","C15.500","C15.801","C15.802","C15.900","C16.000","C16.001","C16.002","C16.100","C16.200","C16.301","C16.400","C16.500","C16.600","C16.800","C16.801","C16.802","C16.803","C16.804","C16.900","C16.903","C17.000","C26.800","D00.200","D13.000","D13.100","D13.101","D17.500x008","D37.100x002","D37.101","D37.102","D37.202","D37.203","K22.205","K25.400x001","K25.500x001","K25.900x001","K25.903","K26.401","K26.501","K26.900x002","K29.500","K31.100x002","K31.101","K31.102","K31.500","K31.501","K31.606","K31.800x806","K31.814","K56.200","K56.700","K91.819","K92.208","Q39.100","Q39.801","Q40.000","Q40.204","Q45.300x104"]
  adrg_zd1=[]
  adrg_ss=["31.7301","40.5000","40.5900x013","40.5902","40.5907","42.3200x006","42.4100","42.4101","42.4102","42.4103","42.4104","42.5100","42.5200","42.5200x005","42.5201","42.5202","42.5403","42.5500x001","43.3x00x003","43.3x01","43.4202","43.4203","43.5x00x003","43.5x00x007","43.5x01","43.5x02","43.5x03","43.6x00x006","43.6x01","43.6x02","43.7x00x001","43.7x02","43.7x03","43.8901","43.9101","43.9102","43.9900x003","43.9900x004","43.9901","43.9902","43.9904","43.9905","43.9906","44.2900x001","44.3801","44.3903","52.6x01","52.7x00"]
  adrg_ss1=[]
  adrg_ss2=[]
  dept_list=[]
  if True and record.zdList[0] in adrg_zd and record.ssList and record.ssList[0] in adrg_ss and record.ssList and intersect(record.ssList,adrg_ss):
    message('符合GB1入组条件，匹配规则：主诊断匹配、主手术匹配、某一手术匹配')
    
    if MDCG_DRG.GB11_group(record):
      return 'GB11'

    if MDCG_DRG.GB15_group(record):
      return 'GB15'

    return 'GB1'
  else:
    return ''

